package com.linws.config;

import com.myrule.LinwsRandomRule;
import com.myrule.LinwsRule;
import com.netflix.loadbalancer.IRule;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.loadbalancer.annotation.LoadBalancerClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

//IRule
@Configuration
//@LoadBalancerClient(name = "springcloud-provider-dept",configuration = LinwsRule.class)
public class ConfigBean {
    //配置负载均衡实现RestTemplate
    @Bean
    @LoadBalanced //Ribbon 是一个客户端负载均衡器
    public RestTemplate getRestTemplate(){

        return new RestTemplate();
    }

    @Bean
    public IRule myRule(){
        return new LinwsRandomRule();
    }

}

